﻿using System;
using System.Windows.Forms;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using HYView;

namespace YJKArch.EditFloor
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class CmdMergeFloor : IExternalCommand
	{
		public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elems)
		{
			Result result;
			try
			{
				if (cmdData == null)
				{
					throw new System.ArgumentNullException("commandData");
				}
				CmdViewType types = (CmdViewType)25;
				if (SwitchView.SetUsableView(types, cmdData) != Autodesk.Revit.UI.Result.Succeeded)
				{
					result = Autodesk.Revit.UI.Result.Failed;
				}
				else
				{
					Autodesk.Revit.DB.Document document = cmdData.Application.ActiveUIDocument.Document;
					FloorMergeEditor floorMergeEditor = new FloorMergeEditor(cmdData);
					while (floorMergeEditor.Mearge(ref msg) == null)
					{
					}
					if (msg.CompareTo("") != 0)
					{
						MessageBox.Show(msg, "盈建科提示");
					}
					result = Autodesk.Revit.UI.Result.Succeeded;
				}
			}
			catch (Exception)
			{
				result = Autodesk.Revit.UI.Result.Failed;
			}
			return result;
		}
	}
}
